package cj.web.tb.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.tb.domain.TBRecommendationItem;

/**
 * 
 * @author 
 *
 */
@DAO
public interface TBRecommendationItemDAO{
	
	@SQL("SELECT * FROM TBRecommendationItem WHERE deleteFlag=1 AND recommendationId=:t.recommendationId ORDER BY updateAt DESC ")
    List<TBRecommendationItem> query(@SQLParam("t") TBRecommendationItem tBRecommendationItem);
	
	@SQL("SELECT count(1) FROM TBRecommendationItem WHERE deleteFlag=1 AND recommendationId=:t.recommendationId ")
    int querySize(@SQLParam("t") TBRecommendationItem tBRecommendationItem);
    
    @SQL("SELECT * FROM TBRecommendationItem WHERE id=:1")
    TBRecommendationItem queryById(int id);
    
    @SQL("INSERT INTO TBRecommendationItem (recommendationId,name,grade,teacher,deleteFlag,createAt,createUser,updateAt,updateUser) VALUES (:t.recommendationId,:t.name,:t.grade,:t.teacher,1,now(),:t.createUser,now(),:t.updateUser)")
    void create(@SQLParam("t") TBRecommendationItem tBRecommendationItem);
	
	@SQL("UPDATE TBRecommendationItem SET recommendationId=:t.recommendationId,name=:t.name,grade=:t.grade,teacher=:t.teacher,updateAt=now(),updateUser=:t.updateUser WHERE id=:t.id")
    void update(@SQLParam("t") TBRecommendationItem tBRecommendationItem);
    
    @SQL("UPDATE TBRecommendationItem SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}